package com.vshining.cryptoki.jna.pkcs11t;

import com.sun.jna.Structure;
import com.vshining.cryptoki.jna.ToString;

import java.util.Arrays;
import java.util.List;

/**
 * <pre>
 * CK_VERSION is a structure that describes the version of a Cryptoki interface,
 * a Cryptoki library, or an SSL implementation, or the hardware or firmware version
 * of a slot or token. It is defined as follows:
 *
 *   typedef struct CK_VERSION {
 *       CK_BYTE major;
 *       CK_BYTE minor;
 *   } CK_VERSION;
 *
 * The fields of the structure have the following meanings:
 *
 *     major    major version number (the integer portion of the version)
 *     minor    minor version number (the hundredths portion of the version)
 *
 * Example: For version 1.0, major = 0x01 and minor = 0x00. For version 2.10, major = 0x02 and
 * minor = 0x0A. The published Cryptoki specifications versions 1.0, 2.01, 2.10, 2.11 and 2.20.
 * </pre>
 *
 * @author Shining Wang <shiningwang@vshining.com>
 */
@SuppressWarnings("unused")
public class CK_VERSION extends Structure {
    public Byte major;
    public Byte minor;

    @Override
    protected List getFieldOrder() {
        return Arrays.asList(
                "major",
                "minor"
        );
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("CK_VERSION{");
        sb.append("major=").append(ToString.toHexString(major));
        sb.append(", minor=").append(ToString.toHexString(minor));
        sb.append('}');
        return sb.toString();
    }
}
